package com.pyb.test;

import com.pyb.config.SpringConfig;
import com.pyb.transactionCon.BookController;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @version 1.0
 * @Author 彭彦彬
 * @Date 2025/1/15 15:40
 * @注释
 */
public class test1 {
    ApplicationContext applicationContext = null;

    @Before
    public void load() {
        applicationContext = new AnnotationConfigApplicationContext(SpringConfig.class);
    }
    @Test
    public void showBeanId() {
        String[] strings = applicationContext.getBeanDefinitionNames();
        for (String string : strings) {
            System.out.println(string);
        }
    }
    @Test
    public void testBuyBook(){
        BookController bookController= (BookController) applicationContext.getBean("bookController");
        bookController.buyBook(1,1);
    }
}
